import { getAction, deleteAction, putAction, putparamsAction, postAction, httpAction } from '@/api/manage'
import { axios as request } from '@/utils/request'
/* ------------------销售合同 begin------------------ */
const erpSaleContractList = (params) => getAction('/salemgt/erpSaleContract/list', params) // 销售合同列表
const erpCustomerList = (params) => getAction('/salemgt/erpCustomer/list', params) // 客户列表
const erpSaleContractAdd = (params) => postAction('/salemgt/erpSaleContract/add', params) // 新建
const erpSaleContractEdit = (params) => putAction('/salemgt/erpSaleContract/edit', params) // 编辑
const erpSaleContractQueryById = (params) => getAction('/salemgt/erpSaleContract/queryById', params) // 编辑
const findUnitListByGoodsId = (params) => getAction('/salemgt/erpSaleContract/findUnitListByGoodsId', params) // 根据商品查单位
const erpSaleContractCompletedById = (params) => getAction('/salemgt/erpSaleContract/completedById', params) // 归档
const erpProductOrderGetListVoByContractId = (params) =>
  getAction('/planmgt/erpProductOrder/getListVoByContractId', params) // 生成订单根据合同查看明细
const erpProductOrderProductOrderSubmit = (params) => postAction('/planmgt/erpProductOrder/productOrderSubmit', params) // 提交订单
const saleContractPaybackAdd = (params) => postAction('/erp/saleContractPayback/add', params) // 添加收款
const saleContractPaybackDelete = (params) => deleteAction('/erp/saleContractPayback/delete', params) // 删除收款
const pageQueryPaybackByContractId = (params) =>
  getAction('/salemgt/erpSaleContract/pageQueryPaybackByContractId', params) // 收款记录分页
const overdueDeliveryPageList = (params) => getAction('/erp/saleReportForms/overdueDeliveryPageList', params) // 逾期未发货报表分页
const getOverdueDeliveryNum = (params) => getAction('/erp/saleReportForms/getOverdueDeliveryNum', params) // 逾期未发货报表
const goodsToBeShippedPageList = (params) => getAction('/erp/saleReportForms/goodsToBeShippedPageList', params) // 待发货商品统计报表分页
const getGoodsToBeShippedNum = (params) => getAction('/erp/saleReportForms/getGoodsToBeShippedNum', params) // 待发货商品统计报表
const salesContractPageList = (params) => getAction('/erp/saleReportForms/salesContractPageList', params) // 合同报表分页
const getSalesContractNum = (params) => getAction('/erp/saleReportForms/getSalesContractNum', params) // 合同报表
const queryNoPermissionPageList = (params) => getAction('mess/messProductOrder/queryNoPermissionPageList', params) // 合同详情生产工单列表
// 物品单位下拉列表,过滤未启用的辅助单位(isUse:0启用，1未启用)
const findUnitListByGoodsIdSync = function (data) {
  return request({
    url: `/salemgt/erpSaleContract/findUnitListByGoodsId?goodsId=${data.goodsId}&isUse=0`,
    method: 'get',
    data,
  })
}

// 销售订单
const getSaleOrderInfoList = (params) => postAction('/sale/saleOrderInfo/list', params) //列表
const saleOrderInfoAdd = (params) => postAction('/sale/saleOrderInfo/add', params) //添加
const saleOrderInfoEdit = (params) => putAction('/sale/saleOrderInfo/edit', params) //编辑
const getSaleOrderInfoQueryCustom = (params) => getAction('/sale/saleOrderInfo/queryCustom', params) //客户下拉框客户查询
const getSaleOrderInfoDelete = (params) => deleteAction('/sale/saleOrderInfo/delete', params) //删除
const getSaleOrderDetail = (params) => getAction('/sale/saleOrderDetail/list', params) //订单详情(物品明细)
const getProduceOrderInfo = (params) => postAction('/produceorder/produceOrderInfo/list', params) //获取详情页的工单列表

/* ------------------销售合同 end------------------ */

/* ------------------采购合同 begin------------------ */
const erpPurchaseContractAdd = (params) => postAction('/purchasemgt/erpPurchaseContract/add', params) // 新建
const erpPurchaseContractEdit = (params) => putAction('/purchasemgt/erpPurchaseContract/edit', params) // 编辑
const selectSupplierList = (params) => getAction('/purchasemgt/erpPurchaseContract/selectSupplierList', params) // 供应商下拉
const selectTaskList = (params) => getAction('/purchasemgt/erpPurchaseContract/selectTaskList', params) // 采购任务下拉
const erpPurchaseContractList = (params) => getAction('/purchasemgt/erpPurchaseContract/list', params) // 采购合同列表
const erpPurchaseContractQueryById = (params) => getAction('/purchasemgt/erpPurchaseContract/queryById', params) // 采购合同详情
const findTaskItemByTaskId = (params) => getAction('/purchasemgt/erpPurchaseContract/findTaskItemByTaskId', params) // 查询任务中商品信息
const erpPurchaseSignOrderAdd = (params) => postAction('/purchasemgt/erpPurchaseSignOrder/add', params) // 签收
const erpPurchaseSignOrderQueryById = (params) => getAction('/purchasemgt/erpPurchaseSignOrder/queryById', params) // 签收单详情
const erpPurchaseContractCompletedById = (params) => getAction('/purchasemgt/erpPurchaseContract/completedById', params) // 归档
const erpPurchaseTaskApplyList = (params) => getAction('/purchasemgt/erpPurchaseTaskApply/list', params) // 采购申请列表
const erpPurchaseContractGetTaskByItemIds = (params) =>
  getAction('/purchasemgt/erpPurchaseContract/getTaskByItemIds', params) // erp根据任务明细ids合并商品明细
const pageQueryPaymentByContractId = (params) =>
  getAction('/purchasemgt/erpPurchaseContract/pageQueryPaymentByContractId', params) // 付款记录分页
const purchaseContractPaymentAdd = (params) => postAction('/erp/purchaseContractPayment/add', params) // 添加付款
const purchaseContractPaymentDelete = (params) => deleteAction('/erp/purchaseContractPayment/delete', params) // 删除付款
/* ------------------采购合同 end------------------ */

/* ------------------供应商 begin------------------ */
const erpSupplierAdd = (params) => postAction('/purchasemgt/erpSupplier/add', params) // 新建
const erpSupplierEdit = (params) => putAction('/purchasemgt/erpSupplier/edit', params) // 编辑
const erpSupplierList = (params) => getAction('/purchasemgt/erpSupplier/list', params) // 列表
const erpSupplierDelete = (params) => deleteAction('/purchasemgt/erpSupplier/delete', params) // 删除
/* ------------------供应商 end------------------ */

const erpSupplierQueryById = (params) => getAction('/purchasemgt/erpSupplier/queryById', params) // 详情
const operateRevoke = (params) => putAction('/proc/operate/revoke', params) // 撤回

// 生产报表-逾期统计
const getOverdueOrderHistogram = (params) => getAction('/mess/messProductReport/getOverdueOrderHistogram', params) // 柱状图
const getOverdueOrderPieChart = (params) => getAction('/mess/messProductReport/getOverdueOrderPieChart', params) // 环形图
const getOverdueStatisticsList = (params) => getAction('/mess/messProductReport/getOverdueStatisticsList', params) // 统计报表
const messProductOverdueReasonList = (params) => getAction('/prodmgt/messProductOverdueReason/list', params) // 逾期原因配置列表
const messProductOverdueReasonAdd = (params) => postAction('/prodmgt/messProductOverdueReason/add', params) // 逾期原因配置添加
const messProductOrderEdit = (params) => putAction('/mess/messProductOrder/edit', params) // 编辑工单

export const contractApi = {
  findUnitListByGoodsIdSync,
  queryNoPermissionPageList,
  messProductOrderEdit,
  messProductOverdueReasonAdd,
  messProductOverdueReasonList,
  getOverdueStatisticsList,
  getOverdueOrderPieChart,
  getOverdueOrderHistogram,
  salesContractPageList,
  getSalesContractNum,
  getGoodsToBeShippedNum,
  goodsToBeShippedPageList,
  getOverdueDeliveryNum,
  overdueDeliveryPageList,
  purchaseContractPaymentDelete,
  purchaseContractPaymentAdd,
  pageQueryPaymentByContractId,
  pageQueryPaybackByContractId,
  saleContractPaybackDelete,
  saleContractPaybackAdd,
  erpPurchaseContractGetTaskByItemIds,
  erpPurchaseTaskApplyList,
  erpProductOrderProductOrderSubmit,
  erpProductOrderGetListVoByContractId,
  erpPurchaseContractCompletedById,
  erpPurchaseSignOrderQueryById,
  erpPurchaseSignOrderAdd,
  operateRevoke,
  erpSupplierEdit,
  findTaskItemByTaskId,
  erpPurchaseContractEdit,
  erpSaleContractCompletedById,
  findUnitListByGoodsId,
  erpPurchaseContractQueryById,
  erpPurchaseContractList,
  selectTaskList,
  selectSupplierList,
  erpSupplierDelete,
  erpSupplierQueryById,
  erpSupplierList,
  erpSupplierAdd,
  erpPurchaseContractAdd,
  erpSaleContractEdit,
  erpSaleContractQueryById,
  erpCustomerList,
  erpSaleContractAdd,
  erpSaleContractList,
  getSaleOrderInfoList,
  saleOrderInfoAdd,
  saleOrderInfoEdit,
  getSaleOrderInfoQueryCustom,
  getSaleOrderInfoDelete,
  getSaleOrderDetail,
  getProduceOrderInfo,
}
